"""
@author: 江同学呀
@file: percolator_field.py
@date: 2024/7/29 21:49
@desc:
    https://www.elastic.co/guide/en/elasticsearch/reference/7.17/percolator.html


"""
from abc import ABC
from typing import Type, Union, Dict, Any

from espc.orm.model.base.base import _Base
from espc.orm.model.mapping.field.base_field.base_field import _BaseField
from espc.utils.build_add_attr import build_add_attr


class PercolatorField(_BaseField, ABC):
    """
    渗滤器 字段
    """
    _field_type: str = "percolator"

    def __init__(self, field_name: str = None, value: Any = None, default: Any = None):
        super(PercolatorField, self).__init__(field_name=field_name, value=value, default=default)
        return

    def __get__(self, instance: _Base, owner: Type["PercolatorField"]) -> Union["PercolatorField", Any]:
        return super(PercolatorField, self).__get__(instance=instance, owner=owner)

    def __set__(self, instance, value: Any):
        super(PercolatorField, self).__set__(instance=instance, value=value)
        return

    def __getattribute__(self, item):
        return super(PercolatorField, self).__getattribute__(item)

    @build_add_attr
    def _build(self) -> Dict:
        raise NotImplementedError(f"{self.__class__.__name__}：特殊字段类型，未仔细研究文档")

